use thiserror::Error;

#[derive(Error, Debug)]
pub enum War3Error {
    #[error("IO error: {0}")]
    Io(#[from] std::io::Error),

    #[error("Protobuf decode error: {0}")]
    ProtobufDecode(#[from] prost::DecodeError),

    #[error("Protobuf encode error: {0}")]
    ProtobufEncode(#[from] prost::EncodeError),

    #[error("Connection closed")]
    ConnectionClosed,

    #[error("Timeout")]
    Timeout,

    #[error("Invalid message type: {0}")]
    InvalidMessageType(i32),

    #[error("Client not found: {0}")]
    ClientNotFound(String),

    #[error("IP pool exhausted")]
    IpPoolExhausted,

    #[error("Invalid IP address: {0}")]
    InvalidIpAddress(String),

    #[error("Invalid message: {0}")]
    InvalidMessage(String),

    #[error("Lock failed: {0}")]
    LockFailed(String),

    #[error("Channel closed")]
    ChannelClosed,

    #[error("Network error: {0}")]
    Network(String),
}

pub type Result<T> = std::result::Result<T, War3Error>;
